/*
 * @(#)Mibsexample2.java
 * Copyright (c) 1996-2003 AdventNet, Inc. All Rights Reserved.
 * Please read the associated COPYRIGHTS file for more details.
 */
package example;

import com.adventnet.snmp.mibs.MibOperations;
import com.adventnet.snmp.snmp2.SnmpAPI;
import com.adventnet.snmp.snmp2.SnmpException;
import com.adventnet.snmp.snmp2.SnmpOID;
import com.adventnet.snmp.snmp2.SnmpSession;
import com.adventnet.snmp.snmp2.SnmpVar;

public class Mibsexample2  {

public static void main(String args[]) {
        
	// start SNMP API
        SnmpAPI api;
        api = new SnmpAPI();
        api.start();
	api.setDebug( true );

	// open session
	SnmpSession session = new SnmpSession(api); 

	try {
            session.open();
        } catch (SnmpException e ) {
	   }
	 
	// set remote host - make sure your agent is running   
	session.setPeername("localhost");
	
	// load MIB
	MibOperations mibOps = new MibOperations();

	try {
	mibOps.loadMibModules("RFC1213-MIB");
	} catch (Exception ex) {
	}
	
	// add OID
	SnmpOID oid = new SnmpOID(".1.3.6.1.2.1.1.1.0");
	
	// build GET request pdu
	SnmpVar var = null;
	try {
	var = session.get(oid);
	} catch (SnmpException e) {
	   }    	
	   
	//print the response pdu   
	//System.out.println(mibOps.toString(var, oid));
	System.out.println(oid.toTagString());
	//System.out.println(var.toTagString());
	
	// close session
	session.close();
	// stop api thread
	api.close();

 }

}

